SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

-- Crea vista Cargos
-- drop view Cargos

create view [dbo].[cargos] as
SELECT	p.idPlaza as cargos_id,
		p.Funcion as tab_cargo_id,
		2 as tab_motivo_creacion_id, -- ver esto
		p.FechaAlta as cargos_fecha_creacion,
		-- cuica nose que es y no se migró......
		case p.RegimenSalarial
			when 12 then 2
			when 13 then 3
			else 2
		end as cargos_tipo,
		p.Observaciones as cargos_obs,
		s.idSubOrganizacion as organismo_id, --p.Organizacion as organismo_id,
		s.Nivel as tab_niv_esc_id,
		p.Asignatura as tab_materia_id,
		d.Curso as cargos_ano,
		d.Division as cargos_seccion,
		p.Horas as cargos_hs,
		p.FechaBaja as cargos_fecha_baja

FROM tb_Plazas p, tb_SubOrganizaciones s, tb_Divisiones d
where	p.SubOrganizacion = s.idSubOrganizacion and
		p.Division = d.idDivision
 
GO
